<template>
  <view class="payment-record-container">
    <!-- 顶部筛选区域 -->
    <view class="filter-header">
      <!-- 状态筛选标签 -->
      <view class="status-tabs">
        <view 
          class="status-tab" 
          :class="{ active: activeStatus === 'all' }"
          @click="switchStatus('all')"
        >
          <text class="tab-text">全部</text>
        </view>
        <view 
          class="status-tab" 
          :class="{ active: activeStatus === 'cancelled' }"
          @click="switchStatus('cancelled')"
        >
          <text class="tab-text">已取消</text>
        </view>
        <view 
          class="status-tab" 
          :class="{ active: activeStatus === 'completed' }"
          @click="switchStatus('completed')"
        >
          <text class="tab-text">已完成</text>
        </view>
        <view 
          class="status-tab" 
          :class="{ active: activeStatus === 'pending' }"
          @click="switchStatus('pending')"
        >
          <text class="tab-text">待收料</text>
        </view>
      </view>
      
      <!-- 时间筛选 -->
      <view class="time-filter" @click="showTimePicker = true">
        <text class="time-label">时间</text>
        <text class="time-arrow">▼</text>
      </view>
    </view>

    <!-- 主要内容区域 -->
    <view class="content-area">
      <!-- 空状态 -->
      <view class="empty-state">
        <view class="empty-icon">📋</view>
        <text class="empty-title">暂无付料记录</text>
        <text class="empty-desc">当前筛选条件下暂无相关记录</text>
      </view>
    </view>

    <!-- 时间选择器弹窗 -->
    <view class="picker-modal" v-if="showTimePicker" @click="showTimePicker = false">
      <view class="picker-content" @click.stop>
        <view class="picker-header">
          <text class="picker-title">选择时间</text>
          <text class="picker-close" @click="showTimePicker = false">×</text>
        </view>
        <view class="picker-options">
          <view 
            class="picker-option" 
            v-for="time in timeOptions" 
            :key="time.value"
            :class="{ active: selectedTimeValue === time.value }"
            @click="selectTime(time.value)"
          >
            <text class="option-text">{{ time.label }}</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'PaymentRecordPage',
  data() {
    return {
      activeStatus: 'pending', // 默认选中待收科
      showTimePicker: false,
      selectedTimeValue: 'all',
      timeOptions: [
        { label: '全部时间', value: 'all' },
        { label: '今天', value: 'today' },
        { label: '昨天', value: 'yesterday' },
        { label: '最近7天', value: 'week' },
        { label: '最近30天', value: 'month' },
        { label: '最近3个月', value: 'quarter' }
      ],
      recordList: [] // 付料记录列表，目前为空
    }
  },
  methods: {
    switchStatus(status) {
      this.activeStatus = status
      this.filterRecords()
      console.log('切换到状态:', status)
    },
    selectTime(value) {
      this.selectedTimeValue = value
      this.showTimePicker = false
      this.filterRecords()
    },
    filterRecords() {
      // 根据筛选条件过滤记录
      console.log('筛选条件:', {
        status: this.activeStatus,
        time: this.selectedTimeValue
      })
      
      // 这里可以根据筛选条件从服务器获取数据
      // 目前显示空状态
    }
  },
  onLoad() {
    console.log('付料记录页面加载')
    this.filterRecords()
  }
}
</script>

<style scoped lang="scss">
@import '@/uni.scss';

.payment-record-container {
  min-height: 100vh;
  background-color: #f5f5f5;
  padding: 0;
}

/* 顶部筛选区域 */
.filter-header {
  background-color: #ffffff;
  padding: 20rpx 26rpx;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2rpx solid #EEEEEE;
}

.status-tabs {
  display: flex;
  flex: 1;
}

.status-tab {
  padding: 10rpx 14rpx;
  background-color: #ffffff;
  border: 2rpx solid #EEEEEE;
  border-radius: 8rpx;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  margin-right: 20rpx;
}

.status-tab.active {
  background-color: #0B1F20;
  border-color: #0B1F20;
}

.tab-text {
  font-size: 28rpx;
  color: #999999;
  transition: color 0.3s ease;
}

.status-tab.active .tab-text {
  color: #ffffff;
}

/* 时间筛选 */
.time-filter {
  display: flex;
  align-items: center;
  gap: 10rpx;
  padding: 20rpx 30rpx;
  background-color: #f8f8f8;
  border-radius: 8rpx;
  border: 2rpx solid transparent;
  transition: all 0.3s ease;
}

.time-filter:active {
  background-color: #f0f0f0;
  border-color: #0B1F20;
}

.time-label {
  font-size: 28rpx;
  color: #666666;
}

.time-arrow {
  font-size: 24rpx;
  color: #999999;
}

/* 主要内容区域 */
.content-area {
  flex: 1;
  padding: 60rpx 30rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-icon {
  font-size: 120rpx;
  color: #cccccc;
  margin-bottom: 30rpx;
}

.empty-title {
  font-size: 32rpx;
  color: #666666;
  margin-bottom: 20rpx;
}

.empty-desc {
  font-size: 28rpx;
  color: #999999;
  line-height: 1.5;
}

/* 弹窗样式 */
.picker-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  z-index: 999;
}

.picker-content {
  width: 100%;
  background-color: #ffffff;
  border-radius: 20rpx 20rpx 0 0;
  padding: 40rpx 30rpx;
  max-height: 60vh;
}

.picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40rpx;
}

.picker-title {
  font-size: 32rpx;
  color: #0B1F20;
}

.picker-close {
  font-size: 40rpx;
  color: #999999;
  padding: 10rpx;
}

.picker-options {
  display: flex;
  flex-direction: column;
  gap: 20rpx;
}

.picker-option {
  padding: 30rpx;
  border-radius: 12rpx;
  border: 2rpx solid transparent;
  transition: all 0.3s ease;
}

.picker-option.active {
  background-color: #F5F5F6;
  border-color: #0B1F20;
}

.option-text {
  font-size: 28rpx;
  color: #0B1F20;
}

.picker-option.active .option-text {
  color: #0B1F20;
}

/* 响应式设计 */
@media screen and (max-width: 750rpx) {
  .status-tabs {
    gap: 15rpx;
  }
  
  .status-tab {
    padding: 15rpx 20rpx;
  }
  
  .tab-text {
    font-size: 26rpx;
  }
}
</style> 